/* $RCSFile: ADNDynImportmap.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynImportmap.cs $
 * $log$
 * Revision 19 2010/10/02 14:01:49  christian.surieux
 *   Corrected a bug in allmost everyADNDyn file for PrimaryFieldVualue
 * Revision 6 2010/08/06 19:56:33  christian.surieux
 *   Added Log to All cs files
 */

/* Copyrights Christian Surieux 2010 */
/* Class ADNDynImportmap */
/* Date 2010-01-06 16:05:34Z */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynImportmap : DynEntity
	{
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.importmap)
            {}

            public override Type DynType
            { get { return typeof(ADNDynImportmap); } }

            public override string DynTypename
            {   get{ return CrmStr.importmap;}}

            public override DynEntity Build()
            {   return new ADNDynImportmap();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynImportmap(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynImportmap(w,PrimaryFieldValue);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynImportmap(w,PrimaryKeyValue);}
        }

        static ADNDynImportmap(){new Ftor();} 
        
        public override bool HasOwningBusinessUnitProperty
        { get { return true; } }
        
        public ADNDynImportmap() : base() { }
        
        public ADNDynImportmap(CRMWrapperBase w,string PrimaryFieldValue)
            : base(w,CrmStr.importmap)
        {
            if ( PrimaryFieldValue != string.Empty )
                name = PrimaryFieldValue;
        }
        
        public ADNDynImportmap(CRMWrapperBase w,Guid CrmId) : base(w,CrmStr.importmap,CrmId) { }
        
        public ADNDynImportmap(CRMWrapperBase w,InternalDynamicEntity e) : base(w,CrmStr.importmap,e,null,null) { }
        
        public ADNDynImportmap(CRMWrapperBase w,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s) : base(w,CrmStr.importmap,e,prop,s) { }
        
        public ADNDynImportmap(ResetWrapperHandler fn,string PrimaryFieldValue)
            : base(fn,CrmStr.importmap)
        {
            if ( PrimaryFieldValue != string.Empty )
                name = PrimaryFieldValue;
        }
        
        public ADNDynImportmap(ResetWrapperHandler fn,Guid CrmId) : base(fn,CrmStr.importmap,CrmId) { }
        
        public ADNDynImportmap(ResetWrapperHandler fn,InternalDynamicEntity e) : base(fn,CrmStr.importmap,e,null,null) { }
        
        public ADNDynImportmap(ResetWrapperHandler fn,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s) : base(fn,CrmStr.importmap,e,prop,s) { }

        /* Properties */

        [CrmDynAttribute(CrmStr.importmap)]
        public Guid importmapid
        {
            get
            { return KeyPropertyValue(CrmStr.importmapid); }
            set
            { AddKeyProperty(CrmStr.importmapid,value); }
        }

        protected override void SetCrmIdProperty(Guid crmId)
        {
            if ( !dicProperty.ContainsKey(CrmStr.importmapid) || KeyPropertyValue(CrmStr.importmapid) != crmId )
                importmapid = crmId;
        }
        public override Guid PrimaryKeyGuidValue
        {
            get
            { return importmapid; }
            set { importmapid = value; }
        }
        
        public override string PrimaryFieldName
        {
            get
            { return CrmStr.name; }
            set
            {}
        }

        /// <summary>
        /// Value contained in the PrimaryField for the DynEntity or empty if no PrimaryField
        /// </summary>
        public override string PrimaryFieldStringValue
        {
            get
            {
                return name;
            }
            set
            {
                name =   value;
            }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public string description
        {
            get
            { return StringPropertyValue(CrmStr.description); }
            set
            { AddStringProperty(CrmStr.description,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public int importmaptype
        {
            get
            { return PicklistPropertyIntValue(CrmStr.importmaptype); }
            set
            { AddPicklistProperty(CrmStr.importmaptype,value); }
        }

        public string importmaptypeLabel
        {
            get
            { return PicklistPropertyLabelValue(CrmStr.importmaptype); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public bool isvalidforimport
        {
            get
            { return BooleanPropertyValue(CrmStr.isvalidforimport); }
            set
            { AddBooleanProperty(CrmStr.isvalidforimport,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public bool iswizardcreated
        {
            get
            { return BooleanPropertyValue(CrmStr.iswizardcreated); }
            set
            { AddBooleanProperty(CrmStr.iswizardcreated,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public override string name
        {
            get
            { return StringPropertyValue(CrmStr.name); }
            set
            { AddStringProperty(CrmStr.name,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public Guid owningbusinessunit
        {
            get
            { return LookupPropertyValue(CrmStr.owningbusinessunit); }
            set
            { AddLookupProperty(CrmStr.owningbusinessunit,CrmStr.businessunit,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public Guid owninguser
        {
            get
            { return LookupPropertyValue(CrmStr.owninguser); }
            set
            { AddLookupProperty(CrmStr.owninguser,CrmStr.systemuser,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public string source
        {
            get
            { return StringPropertyValue(CrmStr.source); }
            set
            { AddStringProperty(CrmStr.source,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public string sourceuseridentifierforsourcecrmuserlink
        {
            get
            { return StringPropertyValue(CrmStr.sourceuseridentifierforsourcecrmuserlink); }
            set
            { AddStringProperty(CrmStr.sourceuseridentifierforsourcecrmuserlink,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public string sourceuseridentifierforsourcedatasourceuserlink
        {
            get
            { return StringPropertyValue(CrmStr.sourceuseridentifierforsourcedatasourceuserlink); }
            set
            { AddStringProperty(CrmStr.sourceuseridentifierforsourcedatasourceuserlink,value); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public int targetentity
        {
            get
            { return PicklistPropertyIntValue(CrmStr.targetentity); }
            set
            { AddPicklistProperty(CrmStr.targetentity,value); }
        }

        public string targetentityLabel
        {
            get
            { return PicklistPropertyLabelValue(CrmStr.targetentity); }
        }

        [CrmDynAttribute(CrmStr.importmap)]
        public string targetuseridentifierforsourcecrmuserlink
        {
            get
            { return StringPropertyValue(CrmStr.targetuseridentifierforsourcecrmuserlink); }
            set
            { AddStringProperty(CrmStr.targetuseridentifierforsourcecrmuserlink,value); }
        }
    }
}